@extends('admin.layouts.app')

@section('title', '权限详情')

@section('content')
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header d-flex justify-content-between align-items-center">
                    <h3 class="card-title">权限详情</h3>
                    <div>
                        @can('edit-permissions')
                        <a href="{{ route('admin.permissions.edit', $permission) }}" class="btn btn-warning">
                            <i class="fas fa-edit"></i> 编辑
                        </a>
                        @endcan
                        <a href="{{ route('admin.permissions.index') }}" class="btn btn-secondary">
                            <i class="fas fa-arrow-left"></i> 返回
                        </a>
                    </div>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6">
                            <table class="table table-bordered">
                                <tr>
                                    <th width="30%">ID</th>
                                    <td>{{ $permission->id }}</td>
                                </tr>
                                <tr>
                                    <th>权限名称</th>
                                    <td>{{ $permission->name }}</td>
                                </tr>
                                <tr>
                                    <th>创建时间</th>
                                    <td>{{ $permission->created_at->format('Y-m-d H:i:s') }}</td>
                                </tr>
                                <tr>
                                    <th>更新时间</th>
                                    <td>{{ $permission->updated_at->format('Y-m-d H:i:s') }}</td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-md-6">
                            <h5>关联角色</h5>
                            @if($permission->roles->count() > 0)
                                <div class="mt-2">
                                    @foreach($permission->roles as $role)
                                        <span class="badge bg-secondary me-2 mb-2">{{ $role->name }}</span>
                                    @endforeach
                                </div>
                            @else
                                <p class="text-muted">暂无关联角色</p>
                            @endif
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection